#include "FlowerMonster.h"

FlowerMonster::FlowerMonster(D3DXVECTOR2 position,EState state):GameObject(position,EObjectType::EFlowerMonster,state)
{
	m_pSprite = new CSprite(ResourceManager::GetIns()->GetTexture(EResource::FlowerMonster_ID),3,1,3,0,2);
	m_pSprite->m_TimeAni = 0.1f;
	highestPos =position + D3DXVECTOR2(0,MOVEAREA);
	lowestPos = position;
	isUp = true;
	canUp = true;
	timer = 0;
}

FlowerMonster::~FlowerMonster()
{
	GameObject::~GameObject();
}

void FlowerMonster::Update(float dt)
{
	m_pSprite->Update(dt);
	if(canUp==false)
	{
		timer+=dt;
		if(timer > 3)
		{
			timer = 0;
			canUp = true;
		}
	}
	if(isUp==true)
	{
		if(m_position.y < highestPos.y && canUp)
		{
			m_position.y += MOVEUPSPEED*dt*60;
		}
		else
		{
			isUp = false;
		}
	}
	else
	{
		if(m_position.y > lowestPos.y)
		{
			m_position.y -= MOVEUPSPEED*dt*60;
		}
		else
		{
			isUp = true;
		}
	}
}

void FlowerMonster::Draw()
{
	GameObject::Draw();
}

void FlowerMonster::SetCanUp(bool b)
{
	canUp = b;
}